﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterSGA.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="SGA.Authentication.Admin.Register" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ajaxToolkit:ToolkitScriptManager ID="ScriptManager" runat="server"></ajaxToolkit:ToolkitScriptManager>
    <asp:UpdatePanel ID="UpdateLoading" runat="server">
        <ContentTemplate>
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-1 sidebar">
                        <ul class="nav nav-sidebar">
                            <li class="active">
                                <asp:Button ID="SaveButton" runat="server" Text="Guardar" CssClass="btn btn-default btn-lg" OnClick="SaveButton_Click" ValidationGroup="InsertItem" Width="100" />
                                <asp:Button ID="UpdateButton" runat="server" Text="Atualizar" Visible="false" OnClick="UpdateButton_Click" CssClass="btn btn-default btn-lg" Width="100" />
                            </li>
                            <li>
                                <asp:Button ID="ClearButton" runat="server" Text="Cancelar" CausesValidation="False" OnClick="ClearButton_Click" CssClass="btn btn-default btn-lg" Width="100" />
                            </li>
                        </ul>
                        <%--Start: Update progress control--%>
                        <asp:UpdateProgress ID="UpdateProgressLoading" runat="server" AssociatedUpdatePanelID="UpdateLoading">
                            <ProgressTemplate>
                                <img alt="Progresso" src="/Images/progress.gif" />
                                Processar...
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                        <%--End: Update progress control--%>
                    </div>

                    <!-- Start: Data source -->
                    <asp:EntityDataSource ID="EDSUsers" runat="server" DefaultContainerName="MailingEntities" ConnectionString="name=MailingEntities" EntitySetName="SystemUsers" EntityTypeFilter="SystemUsers" EnableFlattening="False" EnableDelete="True" EnableInsert="True" EnableUpdate="True" Include="AccessRoles"></asp:EntityDataSource>
                    <asp:ObjectDataSource ID="ODSRoles" runat="server" SelectMethod="GetAllRoles" TypeName="System.Web.Security.Roles"></asp:ObjectDataSource>
                    <!-- End: Data source -->
                    <div class="row">
                        <div class="col-lg-10">
                            <div class="form-group">
                                <div class="row">
                                    <div class="col-lg-3">
                                        <div class="form-group">
                                            <div class="input-group">
                                                <span class="input-group-addon"><i class="fa fa-pencil-square-o"></i></span>
                                                <asp:TextBox ID="NameTextBox" CssClass="form-control" placeholder="Nome" runat="server" Columns="40" />
                                                <asp:RequiredFieldValidator ID="RequiredFieldName" CssClass="myAlert" runat="server" ErrorMessage="Nome é obrigatório." Display="Dynamic" ControlToValidate="NameTextBox" SetFocusOnError="True" ValidationGroup="InsertItem"></asp:RequiredFieldValidator>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="input-group">
                                                <span class="input-group-addon"><i class="fa fa-pencil-square-o"></i></span>
                                                <asp:TextBox ID="UsernameTextBox" placeholder="Username" CssClass="form-control" runat="server" />
                                                <asp:RequiredFieldValidator ID="RequiredFieldUsername" runat="server" ErrorMessage="Username é obrigatório." CssClass="myAlert" Display="Dynamic" ControlToValidate="UsernameTextBox" SetFocusOnError="True" ValidationGroup="InsertItem"></asp:RequiredFieldValidator>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="input-group">
                                                <span class="input-group-addon"><i class="fa fa-pencil-square-o"></i></span>
                                                <asp:TextBox ID="AliasTextBox" placeholder="Alias" CssClass="form-control" runat="server" MaxLength="7" Columns="5" />
                                                <asp:RequiredFieldValidator ID="RequiredFieldAlias" runat="server" ErrorMessage="Alias é obrigatório." CssClass="myAlert" Display="Dynamic" ControlToValidate="AliasTextBox" SetFocusOnError="True" ValidationGroup="InsertItem"></asp:RequiredFieldValidator>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="input-group">
                                                <span class="input-group-addon"><i class="fa fa-pencil-square-o"></i></span>
                                                <asp:TextBox ID="PasswordTextBox" placeholder="Password" CssClass="form-control" runat="server" TextMode="Password" />
                                                <asp:RequiredFieldValidator ID="RequiredFieldPassword" runat="server" ErrorMessage="Password é obrigatório." CssClass="myAlert" Display="Dynamic" ControlToValidate="PasswordTextBox" SetFocusOnError="True" ValidationGroup="InsertItem"></asp:RequiredFieldValidator>
                                                <asp:RegularExpressionValidator ID="RegularExpressionPassword" runat="server" ErrorMessage="Password tem de ter um mínimo de 7 carateres." ValidationGroup="InsertItem" SetFocusOnError="True" ControlToValidate="PasswordTextBox" CssClass="myAlert" Display="Dynamic" ValidationExpression="^.{6,30}$"></asp:RegularExpressionValidator>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="input-group">
                                                <span class="input-group-addon">Utilizador ativo:</span>
                                                <asp:CheckBox ID="EnableCheckBox" CssClass="form-control" Checked="true" runat="server" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="input-group">
                                                <span class="input-group-addon">Nível de acesso:</span>
                                                <asp:DropDownList ID="DropDownListRole" CssClass="form-control" runat="server" ValidationGroup="InsertItem" DataSourceID="ODSRoles"></asp:DropDownList>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="row">
                                    <div class="col-lg-3">
                                        <asp:HiddenField ID="IdUserTextBox" runat="server" Visible="False"></asp:HiddenField>
                                        <asp:ListView ID="LVSystemUsers" runat="server" DataSourceID="EDSUsers" DataKeyNames="Id" OnItemDeleting="LVSystemUsers_ItemDeleting" OnItemCommand="LVSystemUsers_ItemCommand" ClientIDMode="AutoID">
                                            <ItemTemplate>
                                                <ajaxToolkit:HoverMenuExtender ID="HoverMenu" runat="server"
                                                    PopupControlID="PopupMenu"
                                                    PopupPosition="Right"
                                                    TargetControlID="PopupRow"
                                                    PopDelay="50" HoverDelay="20" OffsetX="10" />

                                                <tr runat="server" id="PopupRow">
                                                    <td><%# Eval("Name") %></td>
                                                    <td><%# Eval("Username") %></td>
                                                    <td>
                                                        <asp:CheckBox ID="EnableCheckBox" runat="server" Checked='<%# Eval("Enable") %>' Enabled="false" /></td>
                                                </tr>

                                                <asp:Panel ID="PopupMenu" runat="server" Width="200" Style="display: none">
                                                    <div class="panel panel-default">
                                                        <div class="panel-heading"><%# Eval("Name")%></div>
                                                        <div class="panel-body">
                                                            <asp:LinkButton ID="LinkButtonDelete" runat="server" Text="Remover" CommandName="Delete" CommandArgument='<%#Eval("Id") %>' OnClientClick="javascript:return confirm('Deseja remover o utilizador?')"></asp:LinkButton>
                                                            <br />
                                                            <asp:LinkButton ID="LinkButtonEdit" runat="server" Text="Editar" CommandName="Edit" CommandArgument='<%#Eval("Id") %>'></asp:LinkButton>
                                                        </div>
                                                    </div>
                                                </asp:Panel>
                                            </ItemTemplate>
                                            <LayoutTemplate>
                                                <table runat="server" class="table table-hover table-bordered">
                                                    <tr>
                                                        <th>Nome</th>
                                                        <th>Username</th>
                                                        <th>Ativo</th>
                                                    </tr>
                                                    <tr id="itemPlaceholder" runat="server">
                                                    </tr>
                                                </table>
                                            </LayoutTemplate>
                                        </asp:ListView>
                                    </div>
                                </div>
                            </div>

                            <div id="divStatus">
                                <asp:Label ID="NotificationLabel" runat="server"></asp:Label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
